import type { MedicinesVO, MedicinesForm, MedicinesQuery } from './model';

import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
 * 查询药品库列表
 * @param params
 * @returns 药品库列表
 */
export function medicinesList(params?: MedicinesQuery) {
  return requestClient.get<PageResult<MedicinesVO>>(
    '/business/medicationLibrary/list',
    { params },
  );
}

/**
 * 查询药品库列表
 * @param params
 * @returns 药品库列表---不分页
 */
export function medicinesListAll(params?: MedicinesQuery) {
  return requestClient.get<MedicinesVO[]>('/business/medicationLibrary/listByTradeName', {
    params,
  });
}

/**
 * 导出药品库列表
 * @param params
 * @returns 药品库列表
 */
export function medicinesExport(params?: MedicinesQuery) {
  return commonExport('/business/medicationLibrary/export', params ?? {});
}

/**
 * 查询药品库详情
 * @param id id
 * @returns 药品库详情
 */
export function medicinesInfo(id: ID) {
  return requestClient.get<MedicinesVO>(`/business/medicationLibrary/${id}`);
}

/**
 * 新增药品库
 * @param data
 * @returns void
 */
export function medicinesAdd(data: MedicinesForm) {
  return requestClient.postWithMsg<void>('/business/medicationLibrary', data);
}

/**
 * 更新药品库
 * @param data
 * @returns void
 */
export function medicinesUpdate(data: MedicinesForm) {
  return requestClient.putWithMsg<void>('/business/medicationLibrary', data);
}

/**
 * 删除药品库
 * @param id id
 * @returns void
 */
export function medicinesRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/business/medicationLibrary/${id}`);
}
